package com.puhui.education.util;

import android.view.ViewGroup;
import android.widget.LinearLayout;

/**
 * Created by Administrator on 2016/5/28.
 */
public class DynamicLayoutParamsUtil {
    public final static int WIDTH_MATCH=0;
    public final static int HEIGHT_MATCH=1;
    public final static int BOTH_NO_MATCH=2;

    public static LinearLayout.LayoutParams createLinearLayoutParams(int type,float widthScale, float heightScale) {
        switch (type) {
            case WIDTH_MATCH:
                return  new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int)(ScreenUtil.getScreenHeight()*heightScale));
            case HEIGHT_MATCH:
                return  new LinearLayout.LayoutParams( (int)(ScreenUtil.getScreenWidth()*widthScale),ViewGroup.LayoutParams.MATCH_PARENT);
            case BOTH_NO_MATCH:
                return  new LinearLayout.LayoutParams( (int)(ScreenUtil.getScreenWidth()*widthScale),(int)(ScreenUtil.getScreenHeight()*heightScale));
        }
        return null;
    }
    public static ViewGroup.LayoutParams createViewGroupLayoutParams(int type,float widthScale, float heightScale) {
        switch (type) {
            case WIDTH_MATCH:
                return  new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int)(ScreenUtil.getScreenHeight()*heightScale));
            case HEIGHT_MATCH:
                return  new ViewGroup.LayoutParams( (int)(ScreenUtil.getScreenWidth()*widthScale),ViewGroup.LayoutParams.MATCH_PARENT);
            case BOTH_NO_MATCH:
                return  new ViewGroup.LayoutParams( (int)(ScreenUtil.getScreenWidth()*widthScale),(int)(ScreenUtil.getScreenHeight()*heightScale));
        }
        return null;
    }
}
